<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: tuhao
  Date: 2017/8/16
  Time: 17:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxsearch" data-options="{searchDatagrid:$.CurrentNavtab.find('#workFlow_table')}">
        <fieldset>
            <legend style="font-weight:normal;">条件搜索：</legend>
            <div style="margin:0; padding:1px 5px 5px;">
            <label class="row-label">出错日期：</label>
            <input name="fromTo.from" type="text" value="${from}" data-toggle="datepicker" size="20" placeholder="点击选择日期" data-pattern="yyyy-MM-dd" readonly="true">---
            <input name="fromTo.to" type="text" value="${to}" data-toggle="datepicker" size="20" placeholder="点击选择日期" data-pattern="yyyy-MM-dd" readonly="true">&nbsp;&nbsp;

                <label class="row-label">错误类型：</label>
                    <select name="workflowType" data-toggle="selectpicker" data-width="100">
                        <option value="" selected="">全部</option>
                        <option value="0">买标</option>
                        <option value="1">还款</option>
                        <option value="2">流标</option>
                    </select>&nbsp;&nbsp;

                <div class="btn-group">
                    <button type="submit" class="btn-green" data-icon="search">搜索</button>
                    <button type="reset" class="btn-orange" data-icon="times">重置</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div class="bjui-pageContent">
    <table id="workFlow_table" class="table table-bordered">
    </table>
</div>
<script type="text/javascript">
    var workFlow_table;
    $(function () {
        workFlow_table = $('#workFlow_table').datagrid({
            height: '100%',
            width: '100%',
            fullGrid: true,
            showToolbar: true,
            filterThead: false,
            showCheckboxcol: false,
            delPK: 'id',
            dataUrl: '/admin/workFlow/findPageByHaveError',
            local: "remote",
            inlineEditMult: false,
            saveAll: false,
            delConfirm: true,
            columns: [
                {
                    name: 'name',
                    label: '主键',
                    align: 'center'
                }, {
                    name: 'errMsg',
                    label: '错误信息',
                    align: 'center',
                    render: function (value,data) {
                        return showErrorMsg(value,data);
                    }
                }, {
                    render: doType,
                    name: 'workflowType',
                    label: '类型',
                    align: 'center'
                }, {
                    name: 'execDate',
                    label: '错误时间',
                    align: 'center',
                    pattern: 'yyyy-MM-dd HH:mm:ss',
                    render: function (value) {
                        return value ? value.substr(0, 19) : value
                    },

                    edit: false
                }, {
                    render: showOne,
                    label: '操作',
                    align: 'center'
                }
            ],
            linenumberAll: true,
            paging: {pageSize: 20, pageIndex: 1}
        });
    });

    function showOne(value, data) {

        return '<a href="javascript:;" onclick="toShowOneDetail(\'' + data.id + '\')">' + '查看详情' + '</a>';
    }

    function toShowOneDetail(data) {
        var workFlowId = encodeURIComponent(data);
        BJUI.navtab({
            id: "info_" + data.id,
            url: '/admin/workFlow/errorMsgOne?workFlowId=' + workFlowId,
            title: '查看报错详情'
        });
    }

    function showErrorMsg(value, data) {
        var errMsg = data.errMsg;
        var err = encodeURIComponent(errMsg);
        var html = '<a href="javascript:;" onclick="errorMsgDialog(\'' + data.id + "','" + err + '\')">' + errMsg.substring(0, errMsg.indexOf("[")) + '</a>';
        return html;
    }

    function doType(value, data) {
        var html='';
        <%--<c:set var="newLoanStatus" >${newLoanVo.workflow.workflowType}</c:set>--%>
        <%--var html = "${applicationScope.loanStatusMap.get(newLoanStatus)}";--%>
//        console.log(html);
        if (value===0){
            html='买标';
        }
        if (value===1){
            html='还款';
        }
        if (value===2){
            html='流标';
        }
        return html;
    }

    function errorMsgDialog(name, errMsg) {
        errMsg = decodeURIComponent(errMsg);
        BJUI.dialog({
            id: 'errMsgInfo_' + name,
            name: errMsg,
            html: errMsg,
            title: '' + errMsg.substring(0, errMsg.indexOf("[")) + '',
            width: 1200,
            height: 1200 * 0.618
        });
    }
</script>